package com.wb.code09集合;

import java.util.HashSet;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class Test11_set常用方法 {
    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();
        System.out.println("集合是否为空:" + set.isEmpty());
        System.out.println(set.size() == 0);
        set.add(1);
        set.add(3);
        set.add(4);
        System.out.println("集合是否为空:" + set.isEmpty());
        System.out.println("集合中元素的数量:" + set.size());

        System.out.println(set.remove(1));
        System.out.println(set.remove("aaa"));

        System.out.println("集合中是否包含3:" + set.contains(3));

        System.out.println("清空前:" + set);
// 清空元素
        set.clear();

        System.out.println("清空后:" + set);
    }
}
